package com.xy.iot.common.enums;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;

/**
 * @author Administrator
 * @create 2024-7-3 09:46:19
 * @desc 设备处理枚举
 */

@Getter
public enum DeviceHandleEnum {
	ON_LINE(0, "已连接"),
	BREAK_OFF(1, "已断开"),
	ABNORMAL(2, "处理业务异常"),
	BREAK_RECONNECT(3, "断线重连"),
	;

	@ApiModelProperty("枚举唯一标识")
	private final Integer key;
	@ApiModelProperty("枚举描述")
	private final String value;

	/**
	 * 创建设备处理，构造方法
	 * @param key 枚举唯一标识
	 * @param value 枚举描述
	 */
	private DeviceHandleEnum(Integer key, String value) {
		this.key = key;
		this.value = value;
	}
	
	/**
	 * 根据枚举唯一标识，获取枚举描述
	 * @param key 枚举唯一标识
	 * @return
	 */
	public static String getDeviceHandleEnumName(Integer key) {
		for (DeviceHandleEnum c : DeviceHandleEnum.values()) {
			if (c.getKey().equals(key)) {
				return c.value;
			}
		}
		return null;
	}

}
